home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 47.7z / BS1 part 47 / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf / piarc.lzh.parta / animwr1.rexx < prev    next >
OS/2 REXX Batch file  |  1994-03-17  |  5KB  |  195 lines

  1. /*
  2.    This is the opening phase of the ARexx scripts for making ANIM's
  3.    
  4.    This script gets three things from the user and sticks them into a
  5.    file in ram: so the other three phases of the process will know what
  6.    to do.
  7.    
  8.      1 - The name of the ANIM to create or extend is obtained
  9.      2 - The name template to be used for the individual frames is obtained.
  10.      3 - The number of jiffies between frames.
  11.  */
  12.  
  13. /*
  14.  * open rexxsupport.library -- needed for some functions
  15.  */
  16. if ~show('L',"rexxsupport.library") then do
  17.   if addlib('rexxsupport.library',0,-30,0) then do
  18.       /* everything's ok */
  19.     end;
  20.   else do
  21.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  22.     say 'Cannot operate animr.rexx without this library - sorry!';
  23.     exit 10;
  24.     end;
  25.   end;
  26.  
  27. /*
  28.  * This will automatically direct the script to the proper
  29.  * software, if it is running.
  30.  */
  31. prtnme = 'IP_Port'; /* assume Image Professional */
  32. if show('P','IP_Port') = 0 then do
  33.   if show('P','IM_Port') = 0 then do
  34.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  35.     say "This script requires IP, IM or IM F/c to run!";
  36.     exit(20);
  37.     end;
  38.   else do
  39.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  40.     end;                 /* We make em, user's break em.          */
  41.   end;
  42.  
  43. options;
  44. address;
  45.  
  46.   prevpath = 'ram:'; /* put user in ram to start with... */
  47.  
  48.   if show('C',animpath) = 1 then do
  49.     prevpath = getclip(animpath);
  50.     end;
  51.  
  52.   address(prtnme);
  53.  
  54.   options results;
  55.   'filerequest "'||prevpath||'","'||bufname||'",".anim","Make Anim"';
  56.   animfile = result;
  57.   options;
  58.  
  59.   if animfile = 'FR_CANCELLED' then do
  60.     address(prtnme);
  61.     'imtofront';
  62.     exit 0;
  63.     end;
  64.   else do
  65.     animfile = expandfilename(animfile);
  66.     thispath = gimmepath(animfile);
  67.     call setclip(animpath,thispath);
  68.   end;
  69.  
  70.   options results;
  71.   'gadgets '||'"OP5" "Anim" "OP7" "WORD" "OP7" "LONG" "OP8" "WORD" "OP8" "LONG"'
  72.   atype = result - 1;
  73.   if atype < 0 then do
  74.     address(prtnme);
  75.     'autoredraw 1';
  76.     'allowcancel y'
  77.     'cancel';
  78.     address;
  79.     exit 0;
  80.     end;
  81.  
  82.   options results;
  83.   'askprop '||'"# of jiffies (60th / sec) between frames?" 2 1 180'
  84.   jiffies = result;
  85.   options;
  86.  
  87.   res = open(fhandle,animfile,'read');
  88.   if res ~= 0 then do
  89.     call close(fhandle);
  90.     address(prtnme);
  91.     options results;
  92.     'askyn '||'"Create New ANIM" "Append to Existing ANIM"'
  93.     prefs = result;
  94.     if prefs = 0 then do
  95.       address command 'c:delete >nil: '||animfile;
  96.       end;
  97.     if prefs = 1 then do
  98.       options results;
  99.       'askyn '||'"Truncate before appending" "Append as is"'
  100.       prefs = result;
  101.       if prefs = 0 then do
  102.         address command 'cmpi:ANIMWR -t '||jiffies||' '||atype||' '||animfile;
  103.         res = rc;
  104.         if res ~= 0 then do
  105.           address(prtnme);
  106.           'autoredraw 1';
  107.           'allowcancel y'
  108.           'cancel';
  109.           address;
  110.           exit 0;
  111.           end;
  112.         end;
  113.       end;
  114.     end;
  115.  
  116.   address(prtnme);
  117.   options results;
  118.   'askyn '||'"Create loop frames" "No loop frames"'
  119.   prefs = result;
  120.  
  121.   address command 'cmpi:ANIMWR -c '||jiffies||' '||atype||' '||animfile;
  122.   res = rc;
  123.   if res ~= 0 then do
  124.     address(prtnme);
  125.     'autoredraw 1';
  126.     'allowcancel y'
  127.     'cancel';
  128.     address;
  129.     exit 0;
  130.     end;
  131.  
  132.   call open(fhandle,'ram:IP_ANIMWR.CFG','write');      /* open the file */
  133.   junk = writeln(fhandle, jiffies);
  134.   junk = writeln(fhandle, animfile);
  135.   junk = writeln(fhandle, prefs);
  136.   junk = writeln(fhandle, atype);
  137.   call close(fhandle);                     /* close the file    */
  138.  
  139.   address(prtnme);
  140.   'finish';
  141.   exit 0;
  142.  
  143.  
  144. /*
  145.  * gimmepath
  146.  *
  147.  * This takes the provided argument and sucks the path out of it, then
  148.  * returns that path to the caller, sans file name.
  149.  */
  150. gimmepath:
  151.   arg fullnamegx;
  152.     tempgx = reverse(fullnamegx);
  153.     lengx = length(fullnamegx);   /* get length of string */
  154.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  155.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  156.     seploc = 0; /* assumes current dir, no path supplied */
  157.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  158.       seploc = (lengx - slashdex)+1;
  159.       end;
  160.     else do
  161.       if colondex ~= 0 then do /* we assume we are on a device */
  162.         seploc = (lengx - colondex)+1;
  163.         end;
  164.       end;
  165.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  166.   gxpath = left(fullnamegx,seploc);
  167.   return(gxpath);
  168.  
  169. /*
  170.  * Since this script can't be expected to know where the CD of the user
  171.  * is when this cmd is invoked, we have to check the path the user
  172.  * provides - if it's not specified right from a root, then we have
  173.  * to make it a complete specification from the root.
  174.  */
  175. expandfilename:
  176.   parse arg jfile;
  177.   if index(jfile,':') = 0 then do
  178.     curdir = pragma(D);
  179.     if right(curdir,1) ~= ':' then do
  180.       if right(curdir,1) ~= '/' then do
  181.         if curdir ~= '' then do
  182.           curdir = curdir || '/';
  183.           end;
  184.         end;
  185.       end;
  186.     jfile = curdir||jfile;
  187.     end;
  188.   return(jfile);
  189.  
  190. rvalue:
  191.   wordnum = c2d(readch(fhandle,1)) * 256;
  192.   wordnum = wordnum + c2d(readch(fhandle,1));
  193.   return wordnum;
  194.  
  195.